package cn.agiledata.bank.audit.dao;

import java.util.List;

import cn.agiledata.bank.hibernateBean.UserInfo;
import com.vnv.infrastructure.logic.IPBHibernate3BaseMgr;

public class UserInfoDaoImpl extends IPBHibernate3BaseMgr implements
        IUserInfoDao {
    public UserInfo getUserInfoById(long id) {
        return (UserInfo) getHibernateTemplate().get(UserInfo.class,
                new Long(id));
    }

    public UserInfo[] getUserInfosByFuzzyEmail(String email) {
        String hql = "from UserInfo u where u.email like ?";
        email = "%" + email + "%";
        List resultList = getHibernateTemplate().find(hql, email);
        return (UserInfo[]) resultList.toArray(new UserInfo[0]);
    }

    public UserInfo getUserInfoByEmail(String email) {
        String hql = "from UserInfo u where u.email=?";
        List resultList = getHibernateTemplate().find(hql, email);
        return resultList.size() == 0 ? null : (UserInfo) resultList.get(0);
    }
}
